package com.xmb.common.constants;

import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lyndon on 2019/3/26.
 */
public enum RewardTypeEnum {


    score("score","积分"), // 积分
    bonus("bonus","奖金"),  // 奖金
    balance("balance","余额"); // 余额

    private String type;

    private String desc;

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    RewardTypeEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    private static Map<String, RewardTypeEnum> map = new HashMap<>(2);

    static {
        for (RewardTypeEnum e : values()){
            map.put(e.getType(), e);
        }
    }

    public static boolean contains(String type){
        for(RewardTypeEnum rewardTypeEnum : RewardTypeEnum.values()){
            if(rewardTypeEnum.name().equals(type)){
                return true;
            }
        }
        return false;
    }

    public static RewardTypeEnum getEnumByType(String type) {
        if (StringUtils.isBlank(type)) {
            return null;
        }
        return map.get(type);
    }

}
